/*
 * Departments.java
 *
 * Created on November 9, 2008, 6:19 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package jollylengkono.skripsi.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import org.apache.struts.validator.ValidatorForm;

/**
 * Entity class Departments
 * 
 * @author JollkY
 */
@Entity
public class Departments extends ValidatorForm implements Serializable {

    @OneToMany(mappedBy = "department")
    private List<Members> listWorker;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String departmentName;
    @OneToOne
    private Members departmentChief;
    
    /** Creates a new instance of Departments */
    public Departments() {
    }

    /**
     * Gets the id of this Departments.
     * @return the id
     */
    public Long getId() {
        return this.id;
    }

    /**
     * Sets the id of this Departments to the specified value.
     * @param id the new id
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * Returns a hash code value for the object.  This implementation computes 
     * a hash code value based on the id fields in this object.
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    /**
     * Determines whether another object is equal to this Departments.  The result is 
     * <code>true</code> if and only if the argument is not null and is a Departments object that 
     * has the same id field values as this object.
     * @param object the reference object with which to compare
     * @return <code>true</code> if this object is the same as the argument;
     * <code>false</code> otherwise.
     */
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Departments)) {
            return false;
        }
        Departments other = (Departments)object;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false;
        return true;
    }

    /**
     * Returns a string representation of the object.  This implementation constructs 
     * that representation based on the id fields.
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "jollylengkono.skripsi.model.Departments[id=" + id + "]";
    }

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }

    public Members getDepartmentChief() {
        return departmentChief;
    }

    public void setDepartmentChief(Members departmentChief) {
        this.departmentChief = departmentChief;
    }

    public List<Members> getListWorker() {
        return listWorker;
    }

    public void setListWorker(List<Members> listWorker) {
        this.listWorker = listWorker;
    }
    
}
